package net.zdreamer.shunyi.ui.myinfo;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import net.zdreamer.shunyi.R;
import net.zdreamer.shunyi.utils.WindowUtil;

public class DuihuanActivity extends Activity implements AdapterView.OnItemClickListener {
    private ImageView leftimg;
    private TextView titlecontent;
    private RelativeLayout title;
    private GridView gridView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_duihuan);
        init();
    }

    private void init() {
        title = (RelativeLayout) findViewById(R.id.title_item);
        leftimg = (ImageView) findViewById(R.id.leftimg);
        titlecontent = (TextView) findViewById(R.id.title_content);
        title.setBackgroundResource(R.drawable.newsbiaoti);
        leftimg.setImageResource(R.drawable.backimg);
        titlecontent.setText("兑换界面");
        titlecontent.setTextColor(getResources().getColor(R.color.white));

        leftimg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DuihuanActivity.this.finish();
            }
        });
        gridView = (GridView) findViewById(R.id.grid_duihuan);
        gridView.setOnItemClickListener(this);
        gridView.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return 25;
            }

            @Override
            public Object getItem(int position) {
                return null;
            }

            @Override
            public long getItemId(int position) {
                return 0;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                if (convertView == null) {
                    convertView = LayoutInflater.from(DuihuanActivity.this).inflate(R.layout.photo_item, null);
                }
                View v = convertView.findViewById(R.id.image_phote);
                v.setBackgroundResource(R.drawable.taojinduihuanitem);
//                ViewGroup.LayoutParams lp = v.getLayoutParams();
//              ///  lp.height = (WindowUtil.getWindowSize(DuihuanActivity.this).x - 16) / 3;
//                v.setLayoutParams(lp);
                return convertView;
            }
        });

    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent(this, ShangPinActivity.class);
        startActivity(intent);
    }
}
